<?php

// require_once 'Zend/Gdata/Extension.php';
require_once dirname(__FILE__) . '/../../Extension/Params.php';
require_once dirname(__FILE__) . '/TextValues.php';

class Rass_Extension_VocabParams extends Raws_Extension_Params
{

    // protected $_rootNamespace = 'raws';
    // protected $_rootElement = 'params';
 
    protected $_name = null;
    protected $_xml_namespace = null;
    protected $_description = null;

    public function __construct($name = null, $xml_namespace = null, $description = null) 
    {
        // foreach (Rass::$namespaces as $nsPrefix => $nsUri) {
        //     $this->registerNamespace($nsPrefix, $nsUri);
        // }
        parent::__construct();
        $this->setName($name);
        $this->setXmlNamespace($xml_namespace);
        $this->setDescription($description);
    }
    
    /**
     * Retrieves a DOMElement which corresponds to this element and all
     * child properties.  This is used to build an entry back into a DOM
     * and eventually XML text for application storage/persistence.
     *
     * @param DOMDocument $doc The DOMDocument used to construct DOMElements
     * @return DOMElement The DOMElement representing this element and all
     *          child properties.
     */
    public function getDOM($doc = NULL, $majorVersion = 1, $minorVersion = NULL)
    {
        $element = parent::getDOM($doc);
        if ($this->_name !== null) {
            $element->appendChild($this->_name->getDOM($element->ownerDocument));
        }
        if ($this->_xml_namespace !== null) {
            $element->appendChild($this->_xml_namespace->getDOM($element->ownerDocument));
        }
        if ($this->_description !== null) {
            $element->appendChild($this->_description->getDOM($element->ownerDocument));
        }
        return $element;
    }

    /**
     * Creates individual Entry objects of the appropriate type and
     * stores them as members of this entry based upon DOM data.
     *
     * @param DOMNode $child The DOMNode to process
     */
    protected function takeChildFromDOM($child)
    {
        $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
        
        switch ($absoluteNodeName) {
            case $this->lookupNamespace('raws') . ':' . 'name'; 
                $name = new Rass_Extension_Name();
                $name->transferFromDOM($child);
                $this->_name = $name;
                break;
            case $this->lookupNamespace('raws') . ':' . 'xml_namespace'; 
                $xml_namespace = new Rass_Extension_XmlNamespace();
                $xml_namespace->transferFromDOM($child);
                $this->_xml_namespace = $xml_namespace;
                break;
            case $this->lookupNamespace('raws') . ':' . 'description'; 
                $description = new Rass_Extension_Description();
                $description->transferFromDOM($child);
                $this->_description = $description;
                break;
            default:
                parent::takeChildFromDOM($child);
                break;
        }
    }
    
    public function getName()
    {
        return $this->_name;
    }

    public function setName($value)
    {
        $this->_name = $value;
        return $this;
    }

    public function getXmlNamespace()
    {
        return $this->_xml_namespace;
    }

    public function setXmlNamespace($value)
    {
        $this->_xml_namespace = $value;
        return $this;
    }

    public function getDescription()
    {
        return $this->_description;
    }

    public function setDescription($value)
    {
        $this->_description = $value;
        return $this;
    }

}
